extends "../i_horse8_Hide/i_horse8_Hide.gd"

func init():
    .init()
    name = "紫电之巅"
    resetdata()
    info = "紫电异躯：若周围1格没有队友，则增加自身5%穿透、20%吸血，持续2秒；向随机敌人发射一道可以弹射2次的闪电，首次造成100%物理伤害，下一次弹射伤害为上一次的80%[cd:3秒]\n" + info

func _connect():
	._connect()

#技能计时
func _upS():
    ._upS()
    cnt3 += 1
    if cnt3 == 3:
        cnt3 = 0
        zdyq(masCha)
#紫电异躯
func zdyq(cha):
    var v = [Vector2(-1,1),Vector2(0,1),Vector2(1,1),Vector2(-1,0),Vector2(1,0),Vector2(-1,-1),Vector2(0,-1),Vector2(1,-1)]
    for i in v:
        var tmp = sys.main.matCha(masCha.cell + i)
        if tmp && tmp.get("team") == masCha.team:
            return
    cha.addBuff(zdzd.new(1))
    var chas = cha.getAllChas(1)
    var tmp = sys.rndListItem(chas)
    tmp.addBuff(BF.new(1,att.atk,2))
class zdzd:
	extends Buff
	func _init(lv):
		attInit()
		id = "zdzd"
		life = lv * 2
		att.penL = 0.05
		att.mgiPenL = 0.05
		att.suck = 0.2
		att.mgiSuck = 0.2
#闪电buff
class BF:
	extends Buff
	var healval
	var cnt

	func _init(lv,healval,cnt):
		attInit()
		self.healval = healval
		self.cnt = cnt

	func _connect():
		._connect()
		var chas = masCha.getAllChas(2)
		masCha.hurtChara(masCha,healval,Chara.HurtType.PHY,Chara.AtkType.SKILL)
		cnt -= 1
		healval *= 0.8
		if cnt:
			if chas.size() >=2:
				var ncha = sys.rndListItem(chas)
				while(ncha == masCha || ncha == null):
					ncha = sys.rndListItem(chas)
				if ncha:
					ncha.addBuff(self)
		isDel = true